package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("employee")
public class EmployeeController {
    @Autowired
    private IEmployeeService service;

    @RequestMapping("add")
    public String add(EmployeeBean employee,int deptId){
        service.add(employee,deptId);
        return "ok";
    }

    @RequestMapping("findByItem")
    public PageInfo<EmployeeBean> findByItem(int pageNO,
               String name, LocalDate startDate,LocalDate endDate){

        return service.findByItem(pageNO,name,startDate,endDate);
    }

    @RequestMapping("del")
    public String del(int id){
        service.del(id);
        return "ok";
    }

    @RequestMapping("update")
    public String update(int id,int deptId,int money){
        service.update(id, deptId, money);
        return "ok";
    }

    @RequestMapping("findById")
    public EmployeeBean findById(int id){

        return service.findById(id);
    }
}
